<?php
class SearchView {
    
    public function searchTypes($types) {
        $returnString = '' ;
        foreach($types as $type) {
            $returnString .= "<a href='?page=search&type=".$type."'>".$type."</a> | " ;
        }
        return $returnString ;
    }
    
    public function searchBox($params) {
        $returnString = "
            <form method='post' action='?page=search&type=".$this->getSearchType()."'>
                <select name='searchParam'> " ;
        foreach($params as $key => $param) {        
            $returnString .= "<option value='$param'>$key</option>" ;
        }
        $returnString .= "</select>
                <input type='text' name='searchValue' /><input type='submit' name='search_submit' value='search' />
            </form>
        " ;
        
        return $returnString ;
    }
    
    public function showResults($results) {
        $returnString = '' ;    
        foreach($results as $result) {
            $returnString .= "<p><a href='?page=showMember&memberId=".$result->memberId."'>".$result->name."</a> <br />" ;
            foreach($result->getBoats() as $boats) {
                $returnString .= $boats->type."<br />" ;
            }
                
            $returnString .= "</p>" ;
        }
        
        return $returnString ;
    }
    
    public function doneSearch() {
        if(isset($_POST['search_submit'])) {
            return TRUE ;
        }
        
        return FALSE ;
    }
    
    public function getSearchType() {
        if(isset($_GET['type'])) {
            return $_GET['type'] ;
        }
        
        return NULL ;
    }
    
    public function getSearchValue() {
        if(isset($_POST['searchValue'])) {
            return $_POST['searchValue'] ;
        }
    }
    
    public function getSearchParam() {
        if(isset($_POST['searchParam'])) {
            return $_POST['searchParam'] ;
        }
    }
    
    
    
}
